<script lang="ts" setup>
import { ref } from "vue";
import { FieldValues } from "plus-pro-components";
import { delTable } from "@/api/apiJson";

defineOptions({
  name: "delete"
});
const props = defineProps({
  params: {
    type: Object
  },
  from_config: {
    type: Object,
    required: true
  },
  businessCode: {
    type: String,
    required: true
  }
});
/**
 * 本行数据
 */
const values = ref<FieldValues>(props.params.row);
const visible = ref(true);
const emit = defineEmits(["search"]);

// ============================业务操作========================================
async function handleConfirm() {
  await delTable(props.businessCode, {
    id: values.value[`${props.businessCode}`]["id"]
  }).then(() => {
    emit("search");
    visible.value = false;
  });
}
</script>

<template>
  <PlusDialog
    v-model="visible"
    :title="props.params.text"
    cancel-text="取消"
    confirm-text="确定"
    @confirm="handleConfirm"
  >
    确认删除此行数据吗？
  </PlusDialog>
</template>
